# install.packages('tmap')
# install.packages('gdalUtils')
# install.packages('ggmap')
# library(ggmap)
library(raster)
## Warning: package 'raster' was built under R version 3.4.4
## Loading required package: sp
## Warning: package 'sp' was built under R version 3.4.4
library(sf)
## Warning: package 'sf' was built under R version 3.4.4
## Linking to GEOS 3.6.1, GDAL 2.2.3, proj.4 4.9.3
library(dplyr)
## Warning: package 'dplyr' was built under R version 3.4.4
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:raster':
##
## intersect, select, union
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
sosData <- read.csv("H:\\SOS_Project\\analysisData\\SOSdata_20180614_forARS.csv")
datumCount <- sosData %>%
group_by(GPS_DATUM) %>%
summarise(count = n())
sosWGS <- sosData %>%
filter(GPS_DATUM=="WGS84") %>%
na.omit()
## Warning: package 'bindrcpp' was built under R version 3.4.4
#
# shortWGS <- slice(sosWGS, 1:5)
# shortWGS <- shortWGS %>%
# mutate(lon = as.numeric(as.character(shortWGS$LONGITUDE_DECIMAL)),
# lat = as.numeric(as.character(shortWGS$LATITUDE_DECIMAL)))
#
# ###trying the process with ggplot
# corvallis <- c(lon = -123.2620, lat = 44.5646)
#
# # Add a maptype argument to get a satellite map
# corvallis_map_sat <- get_map(corvallis, zoom = 3)
#
# #point date set
# coords <- cbind(as.numeric(shortWGS$LONGITUDE_DECIMAL), as.numeric(shortWGS$LATITUDE_DECIMAL))
#
#
# # Edit to display satellite map
# ggmap(corvallis_map_sat) +
# geom_point(aes(lon, lat), data = shortWGS)
nrow(sosWGS)
## [1] 4846
names(sosWGS)
## [1] "NAME" "GENUS" "SPECIES"
## [4] "FAMILY" "ABBREV_NAME" "COLL_DT"
## [7] "COLL_YR" "ACC_NUM" "COLL_NUM"
## [10] "COLL_ID" "SECONDARY_ID" "PHYTOREGION_FULL"
## [13] "SUB_CNT1" "SUB_CNT2" "SUB_CNT3"
## [16] "GEOG_AREA" "LOCALITY" "LATITUDE"
## [19] "LONGITUDE" "LATITUDE_DECIMAL" "LONGITUDE_DECIMAL"
## [22] "GEOREF_SOURCE" "GPS_DATUM" "ALTITUDE"
## [25] "ALTITUDE_UNIT" "LAND_OWNER" "KEYWORD"
## [28] "MISC"
latLonWGS <- sosWGS %>%
mutate(lon = as.numeric(as.character(sosWGS$LONGITUDE_DECIMAL)),
lat = as.numeric(as.character(sosWGS$LATITUDE_DECIMAL))) %>%
filter(!is.na(lon)) %>%
filter(!is.na(lat))
## Warning in evalq(as.numeric(as.character(sosWGS$LONGITUDE_DECIMAL)),
## <environment>): NAs introduced by coercion
## Warning in evalq(as.numeric(as.character(sosWGS$LATITUDE_DECIMAL)),
## <environment>): NAs introduced by coercion
coords <- cbind(latLonWGS$lon, latLonWGS$lat)
nrow(coords)
## [1] 4832
points <- SpatialPointsDataFrame(data = latLonWGS,
coords = cbind(latLonWGS$lon, latLonWGS$lat),
proj4string = CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"))
library(gdalUtils)
## Warning: package 'gdalUtils' was built under R version 3.4.4
library(tmap)
## Warning: package 'tmap' was built under R version 3.4.4
tmap_mode("view")
## tmap mode set to interactive viewing
qtm(shp=points)